package com.wyp168.renrenfilm.core.exception;

import com.wyp168.common.utils.R;
import com.wyp168.renrenfilm.core.enums.ExceptionConstants;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@Slf4j
@RestControllerAdvice
public class RenrenExceptionHandle {

    @ExceptionHandler
    public R handleThrowable(Exception e) {
        log.error("捕获到错误，错误信息:{}\n错误原因:{}", e.getMessage(), e.getCause());
        return R.error(ExceptionConstants.SYSTEM_ERROR.getCode(), ExceptionConstants.SYSTEM_ERROR.getMsg() + ": " + e.getMessage());
    }

}
